package com.chj.design.sk;

import java.util.Date;

public class Code07_Mediator3 {
	public static class ChatRoom {
		public static void showMessage(User user, String message) {
			System.out.println(new Date().toString() + " [" + user.getName() + "] : " + message);
		}
	}

	public static class User {
		private String name;

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public User(String name) {
			this.name = name;
		}

		public void sendMessage(String message) {
			ChatRoom.showMessage(this, message);
		}
	}// 原文出自【易百教程】，商业转载请联系作者获得授权，非商业请保留原文链接：https://www.yiibai.com/design_pattern/mediator_pattern.html

	public static void main(String[] args) {
		User robert = new User("Robert");
		User john = new User("John");

		robert.sendMessage("Hi! John!");
		john.sendMessage("Hello! Robert!");
	}// 原文出自【易百教程】，商业转载请联系作者获得授权，非商业请保留原文链接：https://www.yiibai.com/design_pattern/mediator_pattern.html

}
